package ex.other;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * "奇数流" Union（联合） “偶数流” 的测试
 */
public class OddUnionEvenDataStreamTest {
    public static void main(String[] args) throws Exception {
        // 创建环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);
        // 奇数流
        DataStreamSource<Integer> oddNumStream = env.fromElements(1, 3, 5, 7);
        // 偶数流
        DataStreamSource<Integer> evenStream = env.fromElements(2, 4, 6, 8);
        // 双流联合（union） 且 控制台打印
        oddNumStream.union(evenStream).print();
        // 启动任务
        env.execute("OddUnionEvenDataStreamTest");
    }

}